using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.jewelry
{
[System.Serializable]
public  class JewelryQuenching :   cfg.EditorReadWriter 
 {

    public int id ;
     public string name  = "";
     public cfg.condition.MultiCondition cost  = new cfg.condition.MultiCondition();
     public int guaranteeTime ;
     public System.Collections.Generic.List<cfg.jewelry.ColorRandomAttr> quenchingAttrOrdinary  = new System.Collections.Generic.List<cfg.jewelry.ColorRandomAttr>();
     public System.Collections.Generic.List<cfg.jewelry.ColorRandomAttr> quenchingAttrMiddle  = new System.Collections.Generic.List<cfg.jewelry.ColorRandomAttr>();
     public System.Collections.Generic.List<cfg.jewelry.ColorRandomAttr> quenchingAttrHigh  = new System.Collections.Generic.List<cfg.jewelry.ColorRandomAttr>();
     


    public const int TYPE_ID = 291372820;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(7);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(id);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.BEAN | (3 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_MultiCondition(cost,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (4 << Tag.TAG_SHIFT));  os.WriteInt(guaranteeTime);  
         os.WriteSize(Tag.LIST | (5 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_jewelry_ColorRandomAttr(quenchingAttrOrdinary,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (6 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_jewelry_ColorRandomAttr(quenchingAttrMiddle,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (7 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_jewelry_ColorRandomAttr(quenchingAttrHigh,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   id = os.ReadInt(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.BEAN | (3 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); cost = cfg.Extensions.unmarshal_compatible_cfg_condition_MultiCondition(os); os = _oldOs; break; }   
             case (Tag.INT | (4 << Tag.TAG_SHIFT)):   guaranteeTime = os.ReadInt(); break;  
             case (Tag.LIST | (5 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); quenchingAttrOrdinary = cfg.Extensions.unmarshal_compatible_list_cfg_jewelry_ColorRandomAttr(os); os = _oldOs; break; }   
             case (Tag.LIST | (6 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); quenchingAttrMiddle = cfg.Extensions.unmarshal_compatible_list_cfg_jewelry_ColorRandomAttr(os); os = _oldOs; break; }   
             case (Tag.LIST | (7 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); quenchingAttrHigh = cfg.Extensions.unmarshal_compatible_list_cfg_jewelry_ColorRandomAttr(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "JewelryQuenching");
        ele.WriteStartElement("id"); ele.WriteAttributeString("id", "1"); ele.WriteInt(id); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "2"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("cost"); ele.WriteAttributeString("id", "3"); cfg.Extensions.xml_marshal_cfg_condition_MultiCondition(cost,ele); ele.WriteEndElement();
         ele.WriteStartElement("guaranteeTime"); ele.WriteAttributeString("id", "4"); ele.WriteInt(guaranteeTime); ele.WriteEndElement();
         ele.WriteStartElement("quenchingAttrOrdinary"); ele.WriteAttributeString("id", "5"); cfg.Extensions.xml_marshal_list_cfg_jewelry_ColorRandomAttr(quenchingAttrOrdinary,ele); ele.WriteEndElement();
         ele.WriteStartElement("quenchingAttrMiddle"); ele.WriteAttributeString("id", "6"); cfg.Extensions.xml_marshal_list_cfg_jewelry_ColorRandomAttr(quenchingAttrMiddle,ele); ele.WriteEndElement();
         ele.WriteStartElement("quenchingAttrHigh"); ele.WriteAttributeString("id", "7"); cfg.Extensions.xml_marshal_list_cfg_jewelry_ColorRandomAttr(quenchingAttrHigh,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  id = ele.ReadInt(); break; 
                 case 2:  name = ele.ReadString2(); break; 
                 case 3:  cost = cfg.Extensions.xml_unmarshal_cfg_condition_MultiCondition(ele); break; 
                 case 4:  guaranteeTime = ele.ReadInt(); break; 
                 case 5:  quenchingAttrOrdinary = cfg.Extensions.xml_unmarshal_list_cfg_jewelry_ColorRandomAttr(ele); break; 
                 case 6:  quenchingAttrMiddle = cfg.Extensions.xml_unmarshal_list_cfg_jewelry_ColorRandomAttr(ele); break; 
                 case 7:  quenchingAttrHigh = cfg.Extensions.xml_unmarshal_list_cfg_jewelry_ColorRandomAttr(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "id":  id = ele.ReadInt(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "cost":  cost = cfg.Extensions.xml_unmarshal_cfg_condition_MultiCondition(ele); break; 
                 case "guarantee_time":  guaranteeTime = ele.ReadInt(); break; 
                 case "quenching_attr_ordinary":  quenchingAttrOrdinary = cfg.Extensions.xml_unmarshal_list_cfg_jewelry_ColorRandomAttr(ele); break; 
                 case "quenching_attr_middle":  quenchingAttrMiddle = cfg.Extensions.xml_unmarshal_list_cfg_jewelry_ColorRandomAttr(ele); break; 
                 case "quenching_attr_high":  quenchingAttrHigh = cfg.Extensions.xml_unmarshal_list_cfg_jewelry_ColorRandomAttr(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
